import request from '@/utils/request'

// 替换规则相关API
export const ruleApi = {
    // 获取所有规则
    getRules() {
        return request.get('/ctrip/replace-rules')
    },
    // 获取启用的规则
    getEnabledRules() {
        return request.get('/ctrip/replace-rules/enabled')
    },
    // 创建规则
    createRule(data) {
        return request.post('/ctrip/replace-rules', data)
    },
    // 更新规则
    updateRule(id, data) {
        return request.put(`/ctrip/replace-rules/${id}`, data)
    },
    // 删除规则
    deleteRule(id) {
        return request.delete(`/ctrip/replace-rules/${id}`)
    },
    // 切换规则状态
    toggleRule(id, enabled) {
        return request.put(`/ctrip/replace-rules/${id}/toggle`, null, { params: { enabled } })
    },
    // 测试规则
    testRules(content) {
        return request.post('/ctrip/replace-rules/test', { content })
    }
}